//
//  RootView.m
//  UI4_Delegate限时代码3
//
//  Created by dllo on 15/11/12.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "RootView.h"

@interface RootView ()<UITextFieldDelegate>

@end

@implementation RootView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubviews];
    }
    return self;
}

- (void)createSubviews
{
    self.backgroundColor = [UIColor whiteColor];
    
    self.label1 = [[UILabel alloc] initWithFrame:CGRectMake(80, 100, 80, 30)];
    self.label1.text = @"账号";
    [self addSubview:self.label1];
    [_label1 release];
    
    self.label2 = [[UILabel alloc] initWithFrame:CGRectMake(80, 150, 80, 30)];
    self.label2.text = @"密码";
    [self addSubview:self.label2];
    [_label2 release];
    
    self.textF1 = [[UITextField alloc] initWithFrame:CGRectMake(200, 100, 150, 30)];
    self.textF1.placeholder = @"邮箱地址或用户名";
    self.textF1.delegate = self;
    [self addSubview:self.textF1];
    [_textF1 release];
    
    self.textF2 = [[UITextField alloc] initWithFrame:CGRectMake(200, 150, 150, 30)];
    self.textF2.placeholder = @"4-12位字符";
        self.textF2.delegate = self;
    [self addSubview:self.textF2];
    [_textF2 release];
    
    self.button = [UIButton buttonWithType:UIButtonTypeCustom];
    self.button.frame = CGRectMake(150, 200, 80, 30);
    self.button.backgroundColor = [UIColor blackColor];
    [self.button setTitle:@"立即登录" forState:UIControlStateNormal];
    [self addSubview:self.button];
    
    self.label1 = [[UILabel alloc] initWithFrame:CGRectMake(80, 100, 80, 30)];
    self.label1.text = @"账号";
    [self addSubview:self.label1];
    [_label1 release];

    self.tapGR = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction)];
    [self addGestureRecognizer:self.tapGR];
    [_tapGR release];
    
    
}

- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [textField resignFirstResponder];
    return YES;
}

- (void)tapAction
{
    [self.textF1 resignFirstResponder];
        [self.textF2 resignFirstResponder];
}



@end
